#pragma once
#include "Drawable.h"
#include "Camera.h"
#include "Model.h"

#include <vector>

using namespace std;

class CBonus;

class CBat :
	public CDrawable
{
//constants declatarions:
private:
	static const float sc_fMinLength;
	static const float sc_fMaxLength;

public:
	CBat(float3 f3Position, double3 d3Color);
	~CBat(void);

	int Draw();
	int Update();
	int Score(int iValue);		// add player's score , @param iValue - score to add
	//moving routines:
	int MoveLeft();
	int MoveRight();
	void SetInitialPos(float3 f3Position);

	//called when player fail to catch the ball and it go out the board on his side:
	int Fail();


	//called when bnus hits player's bat
	int ApplyBonus(CBonus* pBonus);

	//remove all bonuses (i.e. on ball out)
	int ResetBonuses();
	
	// load texture for bat
	static void LoadTexture();
	static void SetModelLeft(CModel* pModel) { m_pModelLeft = pModel; }
	static void SetModelMiddle(CModel* pModel) { m_pModelMiddle = pModel; }
	static void SetModelRight(CModel* pModel) { m_pModelRight = pModel; }

	float GetLength() { return m_fLength; }

	float GetSpeed() { return m_fSpeed; }
	
	int GetLives() { return m_iLives; }
	
	long int GetScore() { return m_liScore; }

	void SetRelease(bool bRelease);
	bool GetRelease() { return (m_iRelease ? true : false); }

	CCamera* GetCamera() {return m_pCamera; }

	int GetType(){return TYPE_BAT;}

	double3 GetColor() { return m_matMaterial.d3Diffuse; }

	void SwitchDynamicCamera(bool bEnabled);

	//bonus methods:
	void Expand();
	void EnableStick();
	void EnableClone(bool bEnabled);
	bool CanClone();
	bool IsSticky();	//returns true, if m_fStickyTime > 0

private:
	float m_fLength;
	float m_fDestLength;
	float m_fSpeed;
	CCamera* m_pCamera;

	static GLuint m_uiTexture;
	static CModel* m_pModelLeft;
	static CModel* m_pModelMiddle;
	static CModel* m_pModelRight;

	dJointID m_jointTrack;

	int SetupMatrices(float3 f3Translation, float3 f3Scale);

	//player-specific values:
	int m_iLives;		//palyer's lives
	long int m_liScore;	//player's score
	int m_iRelease;	//set to number of balls, that player wants to release from trap

	bool m_bOver;		//set if player looses his all lives, and fails again

	//bonuses
	float m_fStickyTime;	//determines if bat is sticky
	bool m_bCanClone;
};
